package com.newworld.basketballfire.service.controller;

import com.newworld.basketballfire.service.delegate.DuesServiceDelegate;
import com.newworld.basketballfire.service.exception.ServiceException;
import com.newworld.basketballfire.service.model.Dues;
import com.newworld.basketballfire.service.model.DuesParams;
import com.newworld.basketballfire.service.model.ListResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * Created by George on 2019/3/3.
 * DuesService
 */
@RequestMapping(value = "/rest/dues")
@Controller
public class DuesService {

    @Autowired
    private DuesServiceDelegate delegate;

    @RequestMapping(method = RequestMethod.POST)
    @ResponseBody
    public Dues addDues(@RequestBody DuesParams duesParams) throws ServiceException {
        return delegate.addDues(duesParams);
    }

    @RequestMapping(method = RequestMethod.PUT)
    @ResponseBody
    public Dues updateDues(@RequestBody DuesParams duesParams) throws ServiceException {
        return delegate.updateDues(duesParams.getId(), duesParams);
    }

    @RequestMapping(method = RequestMethod.PUT, value = "/{id}")
    @ResponseBody
    public Dues updateDuesById(@PathVariable String id, @RequestBody DuesParams duesParams) throws ServiceException {
        return delegate.updateDues(id, duesParams);
    }

    @RequestMapping(method = RequestMethod.DELETE)
    @ResponseBody
    public void deleteDues(@RequestParam String id) throws ServiceException {
        delegate.deleteDues(id);
    }

    @RequestMapping(method = RequestMethod.DELETE, value = "/{id}")
    @ResponseBody
    public void deleteDuesById(@PathVariable String id) throws ServiceException {
        delegate.deleteDues(id);
    }

    @RequestMapping(method = RequestMethod.GET)
    @ResponseBody
    public Dues getDues(@RequestParam String id) throws ServiceException {
        return delegate.getDues(id);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/{id}")
    @ResponseBody
    public Dues getDuesById(@PathVariable String id) throws ServiceException {
        return delegate.getDues(id);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/list")
    @ResponseBody
    public ListResult<Dues> getDuesList(@RequestParam(required = false, defaultValue = "") String id,
                                        @RequestParam(required = false, defaultValue = "") String activityId,
                                        @RequestParam(required = false, defaultValue = "") String userId,
                                        @RequestParam(required = false, defaultValue = "1") Integer pageNo,
                                        @RequestParam(required = false, defaultValue = "10") Integer pageSize) throws ServiceException {
        return delegate.getDuesList(id, activityId, userId, pageNo, pageSize);
    }

}
